package com.example.vm.domain.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;

import com.common.domain.BaseEntity;
import com.example.api.domain.vo.UserVO;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.util.ObjectUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

@Data
@EqualsAndHashCode(callSuper = false)
@TableName(value = "video")
public class Video extends BaseEntity {

    //视频描述
    private String description;
    //视频分类
    private String type;
    //文件表id(视频url)
    private Long url;
    
    //标签
    @NotBlank(message = "标签不能为空")
    private String label;
    //标题
    private String title;
    //是否公开
    private Boolean open;
    //发布者id
    private Long userId;
    //点赞次数

    private Integer likeNum;
    //分享次数
    
    private Integer shareNum;
    //用户背景
    private String cover;
    //收藏次数
    private Integer collectNum;
    //视频时长
    private String duration;
    //视频分类
    @TableField(exist = false)
    private String videoType;
    private Long typeId;
    /**
     * 审核状态
     * 0：审核中
     * 1：审核通过
     * -1：审核不通过
     */
    private Integer auditStatus;
    //审核消息
    private String msg;

    //关联用户
    @TableField(exist = false)
    private UserVO userVo;
    //历史浏览次数
    private Integer historyNum;
    
    //关联分类名称

    //是否点赞

    //是否收藏

    //是否关注

    //用户昵称

    //是否公开
    
    //获取标签
    public List<String> buildLabel(){
        if (ObjectUtils.isEmpty(label)) return Collections.EMPTY_LIST;
//        if(!label.contains("，")){
//            List<String> list = new ArrayList<>();
//            list.add(label);
//            return list;
//        }
//        else {
            return Arrays.asList(label.split(","));
        }
//    }
}
